%{
open Ast
%}

/* Tokens */
%token LTE
%token LT
%token GT
%token COMMA
%token L
%token P
%token <string> INT
%token <string> IDENT
%token EOF

%left L P
%left INT IDENT

/* Points d'entrée */
%type <Ast.req> expression
%start expression
%%

expression:
 | req EOF        { $1 }
;

req:
 | crit                    { RSimpl ($1)    }
 | crit COMMA req          { RMult ($1, $3) }
;

crit:
 | dist LTE INT            { Crit ($1, int_of_string($3)) }
;

dist:
 | L LT str GT           { print_endline $3; L ($3)} /*TODO : enlever les print!*/
 | P LT str GT           { print_endline $3; P ($3)} /*TODO : enlever les print!*/
;

str:
 | IDENT { $1 }
 | IDENT str { ($1) ^ " " ^ ($2) }
;
